/*
 * cfg.h
 *
 *  Created on: Mar 2, 2011
 *      Author: root
 */

#ifndef CFG_H_
#define CFG_H_


//#define M_IP_CFG_FILE_NAME			"c:\\temp\\rcu_ip.cfg"
//#define M_IP_CFG_FILE_NAME_W		"c:\\temp\\rcu_ip_w.cfg"
//#define M_IP_CFG_LINUX_FILE_NAME	"c:\\temp\\rcu_ip_etc.cfg"
#define M_IP_CFG_FILE_NAME			"/gpsclock/rcu_ip.cfg"
#define M_IP_CFG_FILE_NAME_W		"/gpsclock/rcu_ip.cfg"
//#define M_IP_CFG_LINUX_FILE_NAME	"/gpsclock/etc/network/interfaces_1"
#define M_IP_CFG_LINUX_FILE_NAME	"/gpsclock/etc/network/interfaces"

#define M_sicf_MAX_CONTENT 	100
#define M_sicf_MAX_COUNT 	15
#define M_scif_LINUX_CFG_CNT	4 //"address", ... "gateway"
#define M_IP_CFG_PARSING_CHAR	'$'
#define M_IP_CFG_SPACE_CHAR		'#'


#define M_IP_CFG_Remote_IP_INDEX 	5
#define M_IP_CFG_Remote_PORT_INDEX 	6
#define M_IP_CFG_Source_PORT_INDEX 	8 //8

typedef struct
{
	//int count;
	char *key[M_sicf_MAX_COUNT];
	char v[M_sicf_MAX_COUNT][M_sicf_MAX_CONTENT];
	//char *defaultValue[M_sicf_MAX_COUNT];
}st_ip_cfg_file_;

void init_user_cfg();
void set_user_cfg(char* key, char *v);
void read_user_cfg();
void read_user_cfg_str(char *buf);
char* make_user_cfg_str();
void write_user_cfg();
void write_ip_cfg();

extern char buf_temp_usr_cfg[1000];
extern st_ip_cfg_file_ sicf;
extern void GetIPconfig(int ii,char *str);

extern int  ExecShellCmd(char *cmd);

#define M_IPCONFIG_TEMP_FILE_NAME	"/if.txt"
#define M_str_HWAddr		"HWaddr "
enum enm_GetIPconfig{ ip_cfg_MAC = 1 };

#define M_SIZE_HWADDR_STR	(3*5+2)
extern char mac_str[M_SIZE_HWADDR_STR+1];

extern int iCntResetFlag;
extern int iIfcofigCnt;
extern int bAlarmFalg;
extern void AssignAlarm();

extern void write_rst_info(char *s);
extern char* read_rst_info();
extern void Init_cfg();
extern int iUdpReset;
extern void shell_do_fork(char *cmd);
extern int iFWUpdate;

extern int iCntPeriodHeartBeat;
extern int iPeriodHeartBeat;

void RecordAlarmEvent(KTI_SubData_Alm_T *ptr);

#define DuringDownloading()	(iTimeOutDownload != 0)

extern int16u total_crc_saved;

#endif /* CFG_H_ */
